#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/sem.h>
#include <sys/ipc.h>
#include <inttypes.h>
#include <time.h>
#include <genrand.h>
#include <hexstr.h>
#include <termParse.h>
#include <termExecute.h>

int main(int argsize, const char **args)
{
    char tmpbuf[256];
    char tmpinput[256];
    termPrintOut(NULL);
    termParseInit(tmpbuf, (uint8_t)sizeof(tmpbuf));
    while(1)
    {
        int i = 0;
        memset(tmpinput, 0, sizeof(tmpinput));
        fgets(tmpinput, sizeof(tmpinput), stdin);
        // logdebugc("instr=%s", getHexStr(tmpinput, strlen(tmpinput)).str);
        do
        {
            if(termParseUpdate(tmpbuf, tmpinput[i]) <= 0)
            {
                continue;
            }
            // logdebugc("rcv len=%d", ((termParseStc *)tmpbuf)->rcvSize);
            termExeUpdate(termPsGetPackPtr(tmpbuf));
            break;
        } while (tmpinput[i++] != '\n');
    }
    return 0;
}